home *** CD-ROM | disk | FTP | other *** search
/ Team Palmtops 7 / Palmtops_numero07.iso / WinCE / SDKWindowsCE / HandHeldPCPro30 / sdk.exe / Jupiter SDK / data1.cab / MFC_Samples / palette / mainfrm.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-02-19  |  2.7 KB  |  127 lines

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "Palette.h"
  6.  
  7. #include "MainFrm.h"
  8. #include "dibdoc.h"
  9. #include "dibview.h"
  10.  
  11. #ifdef _DEBUG
  12. #define new DEBUG_NEW
  13. #undef THIS_FILE
  14. static char THIS_FILE[] = __FILE__;
  15. #endif
  16.  
  17. /////////////////////////////////////////////////////////////////////////////
  18. // CMainFrame
  19.  
  20. IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
  21.  
  22. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  23.     //{{AFX_MSG_MAP(CMainFrame)
  24.     ON_COMMAND(ID_FILE_PALETTE, OnFilePalette)
  25.     ON_WM_CREATE()
  26.     //}}AFX_MSG_MAP
  27. END_MESSAGE_MAP()
  28.  
  29. /////////////////////////////////////////////////////////////////////////////
  30. // CMainFrame construction/destruction
  31.  
  32. CMainFrame::CMainFrame()
  33. {
  34.     m_bPalette = TRUE; // initially use picture pallete
  35. }
  36.  
  37. CMainFrame::~CMainFrame()
  38. {
  39. }
  40.  
  41. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  42. {
  43.     if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  44.         return -1;
  45.  
  46. #if (_WIN32_WCE > 200)
  47.     if(!m_wndCommandBar.Create(this) ||
  48.        !m_wndCommandBar.InsertMenuBar(IDR_MAINFRAME) ||
  49.        !m_wndCommandBar.AddAdornments())
  50.     {
  51.         TRACE0("Failed to create CommandBar\n");
  52.         return -1;      // fail to create
  53.     }
  54. #else // MFC for Windows CE 1.0 and 2.0
  55.     if(!AddAdornments(0))
  56.     {
  57.         TRACE0("Failed to create CommandBar\n");
  58.         return -1;      // fail to create
  59.     }
  60. #endif
  61.  
  62.     return 0;
  63. }
  64.  
  65. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  66. {
  67.     return CFrameWnd::PreCreateWindow(cs);
  68. }
  69.  
  70. /////////////////////////////////////////////////////////////////////////////
  71. // CMainFrame diagnostics
  72.  
  73. #ifdef _DEBUG
  74. void CMainFrame::AssertValid() const
  75. {
  76.     CFrameWnd::AssertValid();
  77. }
  78.  
  79. void CMainFrame::Dump(CDumpContext& dc) const
  80. {
  81.     CFrameWnd::Dump(dc);
  82. }
  83.  
  84. #endif //_DEBUG
  85.  
  86. /////////////////////////////////////////////////////////////////////////////
  87. // CMainFrame message handlers
  88.  
  89. void CMainFrame::OnPaletteChanged(CWnd* pFocusWnd) 
  90. {
  91.     CView* pView = GetActiveView();
  92.     ASSERT(pView != NULL);
  93.  
  94.     // notify all child windows that the palette has changed
  95.     SendMessage(WM_USER, (WPARAM)pView->m_hWnd);
  96. }
  97.  
  98. BOOL CMainFrame::OnQueryNewPalette() 
  99. {
  100.     CView* pView = GetActiveView();
  101.     ASSERT(pView != NULL);
  102.  
  103.     // just notify the target view
  104.     pView->SendMessage(WM_USER, (WPARAM)pView->m_hWnd);
  105.     return TRUE;
  106. }
  107.  
  108. void CMainFrame::OnFilePalette() 
  109. {
  110.     CMenu* menu = GetMenu();
  111.     if(menu)
  112.     {
  113.         menu->CheckMenuItem(ID_FILE_PALETTE, m_bPalette ? MF_UNCHECKED : MF_CHECKED);
  114.         m_bPalette = !m_bPalette;
  115.     }
  116.     CString str;
  117.     if (m_bPalette == MF_UNCHECKED)
  118.         str.LoadString(IDS_UNCHECK);
  119.     else
  120.         str.LoadString(IDS_CHECK);
  121.     ::MessageBox(GetSafeHwnd(), (LPCTSTR)str, _T("Palette"), MB_OK);
  122.     CDibView* pView = (CDibView*)GetActiveView();
  123.     if(pView) 
  124.         pView->ShowPicture(m_bPalette);
  125. }
  126.  
  127.